# -*- coding: utf-8 -*-

import Queue
import threading
import time

queue = Queue.Queue()


class ThreadNum(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.queue = queue

    def run(self):
        while True:
            num = self.queue.get()
            print"i'm num %s" % (num)
            time.sleep(1)
        self.queue.task_done()

def main():
    for i in range(10):
        t = ThreadNum(queue)
        t.setDaemon(True)
        t.start()

    for num in range(10):
        queue.put(num)
    # wait on the queue until everything has been processed
    queue.join()